<template>
      <a-tabs v-model:activeKey="activeKey">
          <a-tab-pane key="1" tab="我的发贴">
              <my-event/>
          </a-tab-pane>
          <a-tab-pane key="2" tab="我的评论" force-render>
              <my-comment/>
          </a-tab-pane>
          <a-tab-pane key="3" tab="通知">
              <my-notification/>
          </a-tab-pane>
          <a-tab-pane v-if="userStore.user.isAdmin" key="9" tab="管理事件帖子">
              <admin-event/>
          </a-tab-pane>
          <a-tab-pane v-if="userStore.user.isAdmin" key="10" tab="管理用户">
              <admin-user/>
          </a-tab-pane>
      </a-tabs>

</template>

<script setup>
import {onMounted, ref, watch} from "vue";
import { useUserStore } from '../stores/user';
import MyEvent from "@/views/home/MyEvent.vue";
import MyComment from "@/views/home/MyComment.vue";
import MyNotification from "@/views/home/MyNotification.vue";
import AdminEvent from "@/views/home/admin/AdminEvent.vue";
import AdminUser from "@/views/home/admin/AdminUser.vue";
import {useRoute, useRouter} from 'vue-router'
const userStore  = useUserStore()
const router = useRouter()
const route = useRoute()
const activeKey = ref('1')

onMounted(() => {
    // alert("mm")
    if(userStore.user.id == null){
        alert("非法进入")
        router.push("/")
    }
    activeKey.value =  route.query.tab;
})

watch(() =>userStore.user.id,(newid)=>{
    if(newid == null){
        alert("已退出，回到首页")
        router.push("/")
    }
})
</script>

<style scoped>

</style>